<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$titles = $_POST['title'];
$admins = $_POST['admin'];
$setting_dexs_array = <<<EOT
\$setting_regist = array(
    'capacity' => '$titles',
    'rate' => '$admins'  
);
EOT;
$pattern = '/\$setting_regist\s*=\s*array\s*\(\s*[^;]*\s*\);/s';
$replacement = $setting_dexs_array;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pzsetting.php?s=space";</script>';